package com.egao.common.publicly.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.egao.common.core.web.PageParam;
import com.egao.common.module.outer.entity.OuterMutual;
import com.egao.common.publicly.entity.PubliclyCareerVO;
import com.egao.common.publicly.mapper.PubliclyOuterMutualMapper;
import com.egao.common.publicly.service.PubliclyOuterMutualService;
import com.egao.common.publicly.utils.CalendarUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * 首页校外双选会接口实现类
 *
 * @author pyx
 */
@Service
public class PubliclyOuterMutualServiceImpl extends ServiceImpl<PubliclyOuterMutualMapper, OuterMutual> implements PubliclyOuterMutualService {
    @Override
    public List<PubliclyCareerVO> listPage(PageParam<PubliclyCareerVO> pageParam) {
        CalendarUtils.putTime(pageParam);
        return baseMapper.listPage(pageParam);
    }

    @Override
    public OuterMutual getId(Integer id) {
        OuterMutual outerMutual = baseMapper.selectById(id);

        if (outerMutual == null) {
            return new OuterMutual();
        }

        //更新点击量
        if (outerMutual.getHits() == null) {
            outerMutual.setHits(0);
        }
        outerMutual.setHits(outerMutual.getHits() + 1);
        baseMapper.updateById(outerMutual);

        return outerMutual;
    }

    @Override
    public Integer allHists(HashMap<String, String> createTimeMap) {
        return baseMapper.allHists(createTimeMap);
    }
}
